package com.gitee.wsl.mathematics.geometry.d2

import com.gitee.wsl.ext.collection.mapReduce
import com.gitee.wsl.mathematics.coordinate.d2.Coordinate2
import com.gitee.wsl.mathematics.geometry.api.LineListShape
import com.gitee.wsl.mathematics.geometry.d2.line.LineShape2d

interface LineListShape2d<N:Number,V: Coordinate2<N, V>>:LineListShape<N,V>,Shape2d<N,V> {

    override val perimeter: N get() = lines.map { it.length  }.sumOf { it.toDouble() } + zero

    override val lines: List<LineShape2d<N, V>>
        get() = proxy.mapReduce{a,b -> createLine(a,b)}

    override fun createLine(a: V, b: V): LineShape2d<N, V>

}

